package com.xiaotou.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.xiaotou.db.dao.CommonDAO;
import com.xiaotou.db.pojo.ActingCareer;
import com.xiaotou.db.pojo.AppUser;
import com.xiaotou.db.pojo.WbUser;
import com.xiaotou.domain.Roles;

@Service
public class UserService {

	private CommonDAO commonDao;

	@Transactional(readOnly = true)
	public WbUser getWbUser(Long userId) {
		return this.commonDao.get(WbUser.class, userId);
	}

	@Transactional(readOnly = true)
	public AppUser getAppUser(Long userId) {
		return this.commonDao.get(AppUser.class, userId);
	}

	public ActingCareer getActingCareer(Long userId, Roles role) {
		final AppUser appUser = this.commonDao.get(AppUser.class, userId);
		return appUser.getActingCareers().get(role.getValue());
	}

	public void setCommonDao(CommonDAO commonDao) {
		this.commonDao = commonDao;
	}

}